
import java.util.ArrayList;
import java.util.Collections;

public class CardDeck 
{
	private ArrayList<Card> cards = new ArrayList<Card>();

	/**
	 * Constructs a new deck with 52 cards. Deck is in order and not shuffled.
	 * Call shuffle() to shuffle.
	 */
	public CardDeck() 
	{
		for (int i = 1; i <= 4; i++) // for suits
		{
			for (int j = 1; j <= 13; j++) // for ranks
			{
				Card card = new Card(j, i); // send to object and set suit/rank
				cards.add(card); // add to ArrayList
			}
		}
	}

	/**
	 * Removes the first card from this deck and returns it.
	 * 
	 * @return firstCard - first card on deck
	 */
	public Card deal() 
	{
		Card firstCard = (cards.get(cards.size() - 1));
		cards.remove(cards.get(cards.size() - 1));
		return firstCard;
	}

	/**
	 * @return Number of cards left in deck.
	 */
	public int getTotalCards() 
	{
		return cards.size();
	}

	/**
	 * Shuffles the deck.
	 */
	public void shuffle() 
	{
		Collections.shuffle(cards);
	}
}